function setCookie(name, value, expires) {
  if (!name) throw Error("name empty");
  if (!value) throw Error("value empty");
  if (expires) {
    let d = new Date();
    d.setTime(d.getTime() + expires * 60 * 1000);
    document.cookie = `${name}=${value}; path=/; expires=${d.toGMTString()}`;
    return;
  }
  document.cookie = `${name}=${value}; path=/;`;
}
function getCookie(name) {
  var arr = document.cookie.split("; ");
  let obj = {};
  arr.forEach((item) => {
    let o = item.split("=");
    obj[o[0]] = o[1];
  });
  if (!name) return obj;
  return obj[name];
}
function clearCookie(name) {
  setCookie(name, "0", -1);
}
